Public Class frm_CartaAuditoria
    Public dtt_Data As DataTable
    Private Sub frm_CartaAuditoria_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Dim dtt_TCese As DataTable
        Dim dtt_Etiquetas As DataTable
        Dim str_Vendors As String
        Dim i As Integer
        Dim dtt_Areas As DataTable
        Dim dtt_ListaCartaAuditoria As New DataTable

        str_Vendors = "("

        If dtt_Data.Rows.Count = 1 Then
            str_Vendors = str_Vendors & "'" & dtt_Data.Rows(i)("VENDOR").ToString & "'"
        Else
            For i = 0 To dtt_Data.Rows.Count - 1
                str_Vendors = str_Vendors & "'" & dtt_Data.Rows(i)("VENDOR").ToString
                If i = dtt_Data.Rows.Count - 1 Then
                    str_Vendors = str_Vendors & "'"
                Else
                    str_Vendors = str_Vendors & "',"
                End If
            Next
        End If

        str_Vendors = str_Vendors & ")"

        'dtt_TCese = TraerDatosReporte("0301647")
        dtt_TCese = TraerDatosReporte(str_Vendors)

        dtt_ListaCartaAuditoria.Columns.Add("CODIGO")
        dtt_ListaCartaAuditoria.Columns.Add("APENOM")
        dtt_ListaCartaAuditoria.Columns.Add("REGLABORAL")
        dtt_ListaCartaAuditoria.Columns.Add("MOTCESE")
        dtt_ListaCartaAuditoria.Columns.Add("FECHACESE")
        dtt_ListaCartaAuditoria.Columns.Add("UBICACION")


        For i = 0 To dtt_TCese.Rows.Count - 1
            dtt_ListaCartaAuditoria.Rows.Add()
            dtt_ListaCartaAuditoria.Rows(i)("CODIGO") = dtt_TCese.Rows(i)("VENDOR").ToString
            dtt_ListaCartaAuditoria.Rows(i)("APENOM") = dtt_TCese.Rows(i)("NOMBRES").ToString
            dtt_ListaCartaAuditoria.Rows(i)("REGLABORAL") = dtt_TCese.Rows(i)("REGPENSIONARIO").ToString '"NO EXISTE EL DATO"
            dtt_ListaCartaAuditoria.Rows(i)("MOTCESE") = dtt_TCese.Rows(i)("RAZONTERMINO").ToString
            dtt_ListaCartaAuditoria.Rows(i)("FECHACESE") = dtt_TCese.Rows(i)("FECHATERMINO").ToString
            dtt_ListaCartaAuditoria.Rows(i)("UBICACION") = dtt_TCese.Rows(i)("NOMBREDEPENDENCIA").ToString

        Next

        dtt_Etiquetas = TraerEtiquetasReporte("CAUD")
        dtt_Etiquetas.Rows(0)("CAMPO1") = dtt_Etiquetas.Rows(0)("CAMPO1") & " " & _
                                                   Format(Now(), "dd") & " de " & _
                                                   Format(Now(), "MMMM") & " de " & _
                                                   Format(Now(), "yyyy")


        dtt_Areas = TraerAreas()

        Dim myReport As New crp_CartaAuditoria

        myReport.OpenSubreport("crp_ListaCartaAuditoria.rpt").SetDataSource(dtt_ListaCartaAuditoria)
        myReport.OpenSubreport("crp_Areas.rpt").SetDataSource(dtt_Areas)
        myReport.SetDataSource(dtt_Etiquetas)
        Me.crv_CartaAuditoria.ReportSource = myReport

        Me.WindowState = FormWindowState.Maximized

    End Sub

End Class